﻿Function Assert-ServiceState($computerName,$serviceName)
{
    Write-Host "Checking Remote Registry on $computerName..."
    $serviceState=Get-Service -ComputerName $computerName -Name $serviceName -ErrorAction SilentlyContinue
    if($serviceState.Status -eq "Stopped")
    {
        Write-Host "Starting service on $computerName..."
        Get-Service -ComputerName $computerName -Name $serviceName -ErrorAction SilentlyContinue | Start-Service -ErrorAction SilentlyContinue
        Write-Host "Done!"
    }
    elseif($serviceState.Status -eq "Running")
    {
        Write-Host "Service $serviceName is running on $computerName"
    }
    else
    {
        Write-Host "Service $serviceName is in"$serviceState.Status"on"$computerName
    }
}